package com.shop.cereshop.agent.controller.wallet;

import com.shop.cereshop.agent.page.user.CereAgentUserVO;
import com.shop.cereshop.agent.page.wallet.AgentWalletVO;
import com.shop.cereshop.agent.service.wallet.AgentWalletService;
import com.shop.cereshop.commons.constant.IntegerEnum;
import com.shop.cereshop.commons.domain.wallet.CereAgentWallet;
import com.shop.cereshop.commons.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * 代理商钱包控制器
 *
 * @author
 * @since 2025-11-14
 */
@Slf4j
@RestController
@RequestMapping("/wallet")
@Api(tags = "代理商钱包管理")
public class AgentWalletController {

  @Autowired
  private AgentWalletService agentWalletService;

  @ApiOperation(value = "代理商钱包查询接口")
  @GetMapping("/getAgentWallet")
  public Result<AgentWalletVO> getAgentWallet(HttpServletRequest request) {
    //获取用户信息
    CereAgentUserVO user = (CereAgentUserVO) request.getAttribute("user");
    if (user == null) {
      return Result.unauthorized();
    }
    AgentWalletVO result = agentWalletService.getWallet(user.getAgentUserId(), IntegerEnum.ROLE_TYPE_AGENT.getCode());
    return Result.success(result);
  }

  @ApiOperation(value= "业务员钱包查询接口")
  @GetMapping("/getSalesmanWallet")
  public Result<AgentWalletVO> getSalesmanWallet(HttpServletRequest request) {
    CereAgentUserVO user = (CereAgentUserVO) request.getAttribute("user");
    if (user == null) {
      return Result.unauthorized();
    }
    return null;
  }

}
